package com.buka.communicate.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.buka.communicate.R;
import com.buka.communicate.entity.User;

import net.neiquan.applibrary.base.MyBaseAdapter;
import net.neiquan.applibrary.utils.ImageUtil;
import net.neiquan.applibrary.utils.PixelUtil;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 作者 ： dyj
 * 时间 ： 2016/12/29.
 */

public class SkillDetailAdapter extends MyBaseAdapter<User, SkillDetailAdapter.ViewHolder> {


    public SkillDetailAdapter(Activity context, List data) {
        super(context, data);
    }

    @Override
    public int getItemCount() {
        return 16;
    }

    @Override
    protected ViewHolder getViewHolder() {
        return new ViewHolder(mInflater.inflate(R.layout.item_skill_detail, null));
    }

    @Override
    protected void onBindViewHolder_(final ViewHolder holder, int position) {
        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//        params1.width= PixelUtil.getScreenWidth(context)/6-4;
        params1.width= (PixelUtil.getScreenWidth(context)-PixelUtil.dp2px(context,10))/6;
        params1.height=(PixelUtil.getScreenWidth(context)-PixelUtil.dp2px(context,10))/6;
        holder.mRootViewLL.setLayoutParams(params1);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.width= PixelUtil.getScreenWidth(context)/6-PixelUtil.dp2px(context,14);
        params.height=(PixelUtil.getScreenWidth(context)-PixelUtil.dp2px(context,10))/6-holder.mSkillContent.getHeight()-PixelUtil.dp2px(context,14);
        params.gravity= Gravity.CENTER;
        holder.mSkillLogo.setLayoutParams(params);
        holder.mRootLL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                holder.mRootLL.setBackground(context.getResources().getDrawable(R.drawable.shape_cornor_line));
                holder.mRootFL.setBackgroundColor(context.getResources().getColor(R.color.colorRed_));
            }
        });
        ImageUtil.loadPicNet("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1510752432679&di=5aee09513d4ce7b6f05cf75f3c260662&imgtype=0&src=http%3A%2F%2Fwww.guaiguai.com%2Fattachments%2F201412%2F01%2F11%2F3nsabz7pd.jpg",holder.mSkillLogo);
    }


    static class ViewHolder extends RecyclerView.ViewHolder {
        @InjectView(R.id.mRootViewLL)
        LinearLayout mRootViewLL;
        @InjectView(R.id.mSkillLogo)
        ImageView mSkillLogo;
        @InjectView(R.id.mRootFL)
        FrameLayout mRootFL;
        @InjectView(R.id.mSkillContent)
        TextView mSkillContent;
        @InjectView(R.id.mRootLL)
        LinearLayout mRootLL;

        ViewHolder(View view) {
            super(view);
            ButterKnife.inject(this, view);
        }
    }
}
